import {Component, OnInit, Input,ViewChild} from '@angular/core';
// import * as Highcharts from 'highcharts';

import {NavController, ActionSheetController, AlertController, NavParams} from 'ionic-angular';
import {DomSanitizer} from '@angular/platform-browser';
import _ from "lodash";
import {Common} from "../../../../providers/common";
import {IrpQjtMoreService} from "./more.service";
import {IrpQjtPersonPage} from "../person/person.component";

@Component({
  selector: "page-irp-panoramagram-more",
  templateUrl: 'more.html',
  providers: [IrpQjtMoreService]
})
export class IrpQjtMorePage {
  // @ViewChild("test") test;
  IrpQjtPersonPage: IrpQjtPersonPage;
  groupIndex;
  datasList=[];
  name = [{name:"张钊",v:"zhangz"}, {name:"张继枫",v:"zhangjf"},{name:"郑婕",v:"zhengj"}, {name:"郑澄然",v:"zhengcr"}, {name:"袁野",v:"yuany"},{name:"严力",v:"yanl"},{name:"谢譞璇",v:"xiexx"},{name:"徐驰",v:"xuc"}
    ,{name:"武幼辉",v:"wuyh"},{name:"王瑞冬",v:"wangrd"},{name:"王琪",v:"wangq"},{name:"吴超",v:"wuc"},{name:"陶玉鸣",v:"taoym"},{name:"田文舟",v:"tianwz"},{name:"司伟",v:"siw"},{name:"申浩",v:"shenh"},
    {name:"孙迪",v:"sd"},{name:"马",v:"mag"},{name:"顾沁",v:"guq"},{name:"观富钦",v:"guanbq"},{name:"费逸",v:"feiy"},{name:"陈樱子",v:"chenyz"},{name:" 初博洋",v:"chuby"},{name:"安哲毅",v:"anzy"}];

  constructor(public navCtrl: NavController,
              public homeService: IrpQjtMoreService,
              public navParams: NavParams) {
    this.groupIndex = this.navParams.get("groupIndex");
    this.setDatasList();

  }
  setDatasList() {
    let x, obj;
    switch (this.groupIndex) {
      case 0:
        x = 50;
        break;
      case 1:
        x = 30;
        break;
      case 2:
        x = 20;
        break;
      case 3:
        x = 20;
        break;
      case 4:
        x = 15;
        break;
      case 5:
        x = 15;
        break;
      case 6:
        x = 20;
        break;
      default:
    }
    _.forEach(this.name, (n, index) => {
      obj = {
        value:n.v,
        name: n.name,
        count: Math.ceil( Math.random()*x)
      };
      console.log(obj.count);
      this.datasList.push(obj);
      this.datasList=_.sortBy(this.datasList, 'count');
      this.datasList = _.reverse(this.datasList);
    })
  }

  goPerson(data) {
    // console.log(this.groupIndex)
    // this.navCtrl.push(IrpQjtPersonPage, {item: data, groupIndex: this.groupIndex});
  }
}

